<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            text-align: center;
            width: 70%;
        }

        label {
            margin-right: 15px;
        }

        button {
            margin-top: 5px;
        }

        .box {
            width: 100%;
            padding: 10px;
            margin: 0px auto;
            display: flex;
            justify-content: space-around;
            flex-wrap: wrap;
        }

        select {
            height: 23px;
            margin: 5px;
        }

        .lessontable {
            width: 50%;
        }

        .showico {
            width: 50px;
            height: 50px;
            border: 1px solid black;
            margin: 5px;
        }

        .white {
            height: 300px;
        }
    </style>
</head>

<body>
    <h2>保险产品</h2>
    <div class="add">
        <h2>新增产品</h2>
        <label for="">产品名称</label><input type="text" id="name"><br>
        <div>
            <label for="">所属种类</label>
            <select name="" id="selectkind">
                <option value="child">儿童保险</option>
                <option value="adult">成人保险</option>
                <option value="oldman">老人保险</option>
                <option value="family">家庭保险</option>
                <option value="travel">旅游保险</option>
            </select>
        </div>
        <button id="addproduct">增加</button>
    </div>
    <div class="add">
        <h2>修改产品</h2>
        <label for="">产品名称</label><input type="text" id="name1"><br>
        <div>
            <label for="">所属种类</label>
            <select name="" id="selectkind1">
                <option value="child">儿童保险</option>
                <option value="adult">成人保险</option>
                <option value="oldman">老人保险</option>
                <option value="family">家庭保险</option>
                <option value="travel">旅游保险</option>
            </select>
        </div>
        <button id="changeproduct">修改</button>
    </div>
    <table>
        <thead>
           <tr>
            <th>编号</th>
            <th>名字</th>
            <th>创建时间</th>
           </tr>
        </thead>
        <tbody id="showproduct">

        </tbody>
    </table>
</body>

</html>
<script src="./utils/jquery-3.4.1.min.js"></script>
<script>
    showproduct()
    //显示保险产品
    function showproduct() {
        $.ajax({
            url: "/products/showproducts",
            type: "get",
            dataType: "json",
            success: function (msg) {
                if (msg.status) {
                    console.log("产品数据获取成功！", msg);
                    let temp = "";
                    msg.data.map((item)=>{
                        temp=`
                        
                        `;
                    }).join("")
                }
            }
        })
    };
    //新增保险产品
    $("#addproduct").click(function () {
        let productName = $("#name").val();
        // let categoryId = $("#selectkind").val;
        // console.log(categoryId);
        $.ajax({
            url: "/products/addproducts",
            type: "post",
            dataType: "json",
            data: {
                productName,
                // categoryId,
            },
            success: function (msg) {
                if (msg.status) {
                    console.log("产品数据新增成功！", msg);
                }
            }
        })
    })
    //修改保险信息
   
</script>